﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class Connect
{
    public ConnectPoint inPoint;
    public ConnectPoint outPoint;

    public Action<Connect> OnRemoveConnect;

    public Connect(ConnectPoint inPoint,ConnectPoint outPoint,Action<Connect> OnRemoveConnect)
    {
        this.inPoint = inPoint;
        this.outPoint = outPoint;
        this.OnRemoveConnect = OnRemoveConnect;
    }
    public void Draw()
    {
        Handles.DrawBezier(
            inPoint.rect.center,
            outPoint.rect.center,
            inPoint.rect.center+Vector2.left*50f,
            outPoint.rect.center-Vector2.left*50f,
            Color.white,
            null,
            2f
            );

        if (Handles.Button((inPoint.rect.center+outPoint.rect.center)*0.5f,
            Quaternion.identity,4,8,Handles.RectangleHandleCap))
        {
            if (OnRemoveConnect!=null)
            {
                OnRemoveConnect(this);
            }
        }
    }
}
